<!DOCTYPE html>
<html>
  <head>
    <title>意见反馈管理</title>
    <include file='public/head'>
    <style>
        .layui-legend-size{font-size:14px !important;}
        .layui-nopadding{padding:0 !important;}
        .layui-overflow{overflow:auto;}
        .layui-nomargin{margin: 0 !important;}
        .layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
        .layui-input{height:30px !important; }
        .layui-form-search-item .layui-inline{margin-bottom: 5px;} 
        .layui-form-search-item label{margin-left: 15px;}
        .layui-table-page {padding: 7px 0px 0px;}
        .layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
        .mytable { table-layout:fixed;}  
        .mytable tr td { text-overflow: ellipsis; -moz-text-overflow:ellipsis; /* for Firefox,mozilla */  
        overflow: hidden; white-space: nowrap;  text-align:left}  
    </style>
</head>
<body>
  <!-- layui-tab开始 -->
  <div class="layui-tab" lay-fliter="demo-tab">
    <!-- 顶部导航菜单开始 -->
    <div class="layui-tab-nav">
      <ul class="layui-tab-title">
          {:getNav('feedback','admin_index/index')};
      </ul>
    </div>
    <!-- 顶部导航菜单结束 -->
    <br>
      
    <!-- 内容开始 -->
    <div class="layui-card">
        
    <!-- 搜索栏开始 -->
        <fieldset class="layui-elem-field layui-field-title layui-field-padding">
        <legend class="layui-legend-size">搜索</legend>
        <form class="layui-form table-bar" action="{:cmf_plugin_url('Feedback://admin_index/index')}" lay-filter="form-bar" method="post">
            <div class="layui-form-search-item">
                
                <div class="layui-inline" >
                    <label>反馈类型</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <select name="type" class="layui-input" lay-verify="" lay-search="">
                            <option value="">全部</option> 
                            <volist name="type" id="vo">
                            <option value="{$vo.title}" <eq name="sear.type" value="{vo.title}">selected</eq> >{$vo.title}</option> 
                            </volist>
                        </select>
                    </div>

                    <label>状态</label>
                    <div class="layui-input-inline" style="width: 150px;">
                        <select name="status" class="layui-input" lay-verify="" lay-search="">
                            <option value="">全部</option> 
                            <option value="1" <eq name="sear.status" value="1">selected</eq> >未读</option> 
                            <option value="2" <eq name="sear.status" value="2">selected</eq>  >已读</option>
                        </select>
                    </div>
                </div>
                
                <label>手机号</label>
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width:120px;">
                    <input type="text" class="layui-input" id="test2" name="mobile" value="{$sear.mobile}">
                    </div>
                </div>

                <div class="layui-inline">
                <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>
                </div>
                
            </div>
        </form>
        </fieldset>
    <!-- 搜索栏结束 -->
    

    <!-- 表头按钮开始 -->
    <div class="layui-card-header layui-bg-gray layui-bottom ">
        <a href="javascript:;" class="layui-btn layui-btn-xs layui-bg-red delete-btn" >
            <i class="layui-icon">&#xe640;</i>批量删除
        </a>
        <a href="javascript:;" class="layui-btn layui-btn-xs  sign-btn" >
            <i class="layui-icon">&#xe605;</i>批量已读/未读
        </a>
        <a href="javascript:;" class="layui-btn layui-btn-xs type-btn " >
            <i class="layui-icon">&#xe620;</i>设置类型
        </a>
    </div>    
    <!-- 表头按钮结束 -->

    <!-- 数据表格开始 -->
    <form method="post" id="f">
    <table class="layui-table layui-nomargin mytable" >
        <thead>
            <tr>
                <th width="20px" >
                    <input type="checkbox"  id="check-box-all" class='layui-form-checkbox'>
                </th>
                <th>ID</th>
                <th>反馈类型</th>
                <th>手机号码</th>
                <th width="600px">意见内容</th>
                <th>图片</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            
        </thead>
        <tbody>
            <volist  name="list" id="vo">
                <tr lay-fliter="test3">
                    <th>
                        <input type="checkbox" class="check-box " name="id[]" value="{$vo.id}">
                    </th>
                    <td>{$vo.id}</td>
                    <td>{$vo.type}</td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.content}</td>
                    <td>
                        <if condition="$vo.img neq ''"> 有<else>无
                            <!-- <img src="{$vo.img}" height="100px"> -->
                        </if>
                    </td>
                    <td>
                        <eq name="vo.status" value="1" >未读</eq>
                        <eq name="vo.status" value="2" >已读</eq>
                    </td>
                    <td>
                        <button type="button" onclick="view({$vo.id})"class="layui-btn layui-btn-primary layui-btn-xs" title="查看"><i class="layui-icon">&#xe602;</i></button>
                    </td>
                </tr>
            </volist>
        </tbody>
    </table>


    <!--分页开始-->
    <div class="layui-table-page">
        <div id="layui-table-page1">
            <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
                {$page|default=''}
            </div>
        </div>
    </div>
    <!-- 分页结束 -->

    </form>
    <!-- 数据表格结束 -->
    </div>
    <!-- 内容结束 -->
    
  </div>
  <!-- layui-tab开始 -->
</body>

<include file="public/scripts"/>
<script>
     //全选/取消
     $('#check-box-all').on('click',function(){	
        $('.check-box').prop('checked',$('#check-box-all').prop('checked'));
    }); 


/**
 * 查看
 */
function view(id)
{
    layer.open({
        title:'查看',
        type: 2,
		shadeClose: true,//是否点击遮罩关闭
        btn:["确定","取消"],
        area: [60+'%', window.innerHeight-150+'px'],
        content: "{:cmf_plugin_url('Feedback://admin_index/viewPage')}?id="+id,
        yes:function(index,layero){
           //子页面的请求操作都放子页面
           var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.tijiao();
        },btn2:function(index, layero){
			}
    })
}


/**
 * 已读
 */
 $('.sign-btn').on('click',function (){
    var id_str = $('input[type=checkbox]:checked').map(function(){return this.value}).get().join(',');
    let id = $(this).data('id');
    if(id == undefined) id = id_str;
    layer.confirm('确定已读吗？',{icon:3,title:'提示',btn:['确定','取消']},function(index,layero){
            $.ajax({
                url:"{:cmf_plugin_url('Feedback://admin_index/readUnread')}",
                type:'post',
                data:{id:id},
                success:function(data){
                    let icon = ( data.code == 200 ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
})




/**
 * 设置反馈类型
 */
 $('.type-btn').on('click',function (){
    layer.open({
        title:'设置反馈类型',
        type: 2,
		shadeClose: true,//是否点击遮罩关闭
        shade: 0.8,
        area: [window.innerWidth+'px', window.innerHeight+'px'],
        btn:['关闭'],//操作按钮
        fixed:false,
        maxmin:true,
        content: "{:cmf_plugin_url('Feedback://admin_index/config')}",

    });
layer.full(index);

})

/**
 * 删除
 */
 $('.delete-btn').on('click',function(){
        var id_str = $('input[type=checkbox]:checked').map(function(){return this.value}).get().join(',');
        let id = $(this).data('id');
        if(id == undefined) id = id_str;
        //询问
        layer.confirm('确定要删除吗？',{icon:3,title:'提示',btn:['删除','取消']}
        ,function(index,layero){
            $.ajax({
                url:"{:cmf_plugin_url('Feedback://admin_index/delete')}",
                type:'post',
                data:{id:id},
                success:function(data){
                    let icon = ( data.code == 200 ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
       
    })

</script>
</html>